package com.houdoudou.supplier;

import java.util.Arrays;
import java.util.List;


import android.content.Context;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

public class FirstIndextAdapter extends BaseAdapter {
	Context context;
	List<String> first_indext_list;
	private LayoutInflater mInflater; 
	int current_selected_position=100;
	String[] first_index_array={"产品管理 ","订单管理","退款管理","送货员","自提柜","结算","设置"};
	public FirstIndextAdapter(Context context) {
		
		 mInflater=LayoutInflater.from(context);  
		 first_indext_list=Arrays.asList(first_index_array);
	}
	
	
	 @Override  
	    public int getCount() {  
	        return first_indext_list.size();  
	    }  
	     
	    @Override  
	    public Object getItem(int position) {  
	        return position;  
	    }  
	    private ViewHolder vh    =new ViewHolder();  
	    private static class ViewHolder {  
	        private Button title ;  
	      
	    }  
	    @Override  
	    public long getItemId(int position) {  
	        return position;  
	    }  
	  
	    @Override  
	    public View getView(int position, View convertView, ViewGroup parent) {  
	    	 final int first_index_position=position;
	        if(convertView==null){  
	            convertView = mInflater.inflate(R.layout.list_first_index, null);  
	            vh.title=(Button)convertView.findViewById(R.id.title_list_first_indext);  
	            
	            convertView.setTag(vh);  
	        }else{  
	            vh=(ViewHolder)convertView.getTag();  
	        }  
	        vh.title.setText(first_indext_list.get(position)); 
	        if(current_selected_position==first_index_position)   vh.title.setBackgroundResource(R.drawable.first_index_selected_style);
	        vh.title.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					
					current_selected_position=first_index_position;
				Message msg = new Message();               
                 msg.what=1;
                // toMain.obj=checkRelayString;
                 msg.arg1=first_index_position;
               
			SupplierMainActivity.myMainHandler.sendMessage(msg);
		
					
				}
			});
	        return convertView;  
	    }  
	

}
